package com.jspx.txweb.view;

import com.jspx.txweb.annotation.HttpMethod;
import com.jspx.txweb.annotation.Safety;
import com.jspx.txweb.support.ActionSupport;
import com.jspx.utils.DateUtil;
import com.jspx.utils.RandomUtil;
import com.jspx.utils.StringUtil;

/**
 * Created by chenyuan on 2016/1/4
 * 解决关注的问题，验证后跳转到对应的页面,禁止分享，转发等功能
 * 本页单独作为一个页面，在跳转到主体也没
 * com.jspx.txweb.view.VerifyJumpView
 */
@HttpMethod(caption="微信跳转验证")
public class VerifyJumpView extends ActionSupport {
    public static final String  KEY_VerifyCode = "verifyCode";
    private String verifyCode = RandomUtil.getRandomAlphanumeric(4)+DateUtil.toString("yyMMddHHmmssS");

    public VerifyJumpView()
    {

    }

    public String getVerifyCode() {
        return verifyCode;
    }

    private String link = StringUtil.empty;
    @Safety(request = false)
    public void setLink(String link) {
        this.link = link;
    }

    @Override
    public String execute() throws Exception {
        session.setAttribute(KEY_VerifyCode,verifyCode);
        if (!StringUtil.isNULL(link))
        {
            response.sendRedirect(link+"?" + KEY_VerifyCode + "="+verifyCode);
        }
        return NONE;
    }
}
